package com.charging.ruoyi.product.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.charging.ruoyi.product.domain.RuoyiProductPO;
import com.charging.ruoyi.product.service.IRuoyiProductPOService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 测试代码生成Controller
 * 
 * @author ruoyi
 * @date 2025-08-21
 */
@RestController
@RequestMapping("/system/product")
public class RuoyiProductPOController extends BaseController
{
    @Autowired
    private IRuoyiProductPOService ruoyiProductPOService;

    /**
     * 查询测试代码生成列表
     */
    @PreAuthorize("@ss.hasPermi('system:product:list')")
    @GetMapping("/list")
    public TableDataInfo list(RuoyiProductPO ruoyiProductPO)
    {
        startPage();
        List<RuoyiProductPO> list = ruoyiProductPOService.selectRuoyiProductPOList(ruoyiProductPO);
        return getDataTable(list);
    }

    /**
     * 导出测试代码生成列表
     */
    @PreAuthorize("@ss.hasPermi('system:product:export')")
    @Log(title = "测试代码生成", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RuoyiProductPO ruoyiProductPO)
    {
        List<RuoyiProductPO> list = ruoyiProductPOService.selectRuoyiProductPOList(ruoyiProductPO);
        ExcelUtil<RuoyiProductPO> util = new ExcelUtil<RuoyiProductPO>(RuoyiProductPO.class);
        util.exportExcel(response, list, "测试代码生成数据");
    }

    /**
     * 获取测试代码生成详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:product:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ruoyiProductPOService.selectRuoyiProductPOById(id));
    }

    /**
     * 新增测试代码生成
     */
    @PreAuthorize("@ss.hasPermi('system:product:add')")
    @Log(title = "测试代码生成", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RuoyiProductPO ruoyiProductPO)
    {
        return toAjax(ruoyiProductPOService.insertRuoyiProductPO(ruoyiProductPO));
    }

    /**
     * 修改测试代码生成
     */
    @PreAuthorize("@ss.hasPermi('system:product:edit')")
    @Log(title = "测试代码生成", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RuoyiProductPO ruoyiProductPO)
    {
        return toAjax(ruoyiProductPOService.updateRuoyiProductPO(ruoyiProductPO));
    }

    /**
     * 删除测试代码生成
     */
    @PreAuthorize("@ss.hasPermi('system:product:remove')")
    @Log(title = "测试代码生成", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ruoyiProductPOService.deleteRuoyiProductPOByIds(ids));
    }
}
